package shop.client.ui.gui;

import java.util.List;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import shop.common.valueobjects.Kategorie;

@SuppressWarnings("serial")
public class CategoryTableModel extends DefaultTableModel {

	private Vector<String> columnNames;
	private Vector<Vector<String>> data;
	
	public CategoryTableModel(List<Kategorie> kat) {
		super();
		
		columnNames = new Vector<String>();
		columnNames.add("ID");
		columnNames.add("Titel");
		
		data = new Vector<Vector<String>>();
		updateDataVector(kat);
	}

	public void updateDataVector(List<Kategorie> kat) {
		data.clear();
		
		for (Kategorie k: kat) {
			Vector<String> kategorieVector = new Vector<String>();
			kategorieVector.add(String.valueOf(k.getNummer()));
			kategorieVector.add(k.getTitel());
			data.add(kategorieVector);
		}
		
		setDataVector(data, columnNames);
	}
}
